/*
 * myprintf.c
 *
 *  Created on: Sep 28, 2012
 *      Author: bel671
 */

#include "myprintf.h"

#define MAX_FILLER 11

char* ltoa(char *p, long num, unsigned radix) {
  int i;
  char *q;

  q = p + MAX_FILLER;
  do {
    i = (int)(num % radix);
    i += '0';
    if (i > '9')
      i += 'A' - '0' - 10;
    *--q = i;
  } while ((num /= radix) != 0);

  i = (int)(p + MAX_FILLER - q);
  do
    *p++ = *q++;
  while (--i);

  return p;
}


